//定义token等的常量键名
const TokenKey = 'accessToken'    //token密钥
const RefreshTokenKey = 'refreshToken'   //上面那个过期了，下面这个就可以重新获取到上面的密钥

//设置保存token和refreshToken
export function setToken(token, refreshToken) {
    localStorage.setItem(TokenKey, token)
    localStorage.setItem(RefreshTokenKey, refreshToken)
}

//获取token
export function getToken() {
    return localStorage.getItem(TokenKey)
}

//获取refreshToken
export function getRefreshToken() {
    return localStorage.getItem(RefreshTokenKey)
}

//清除token和refreshToken
export function clearToken() {
    localStorage.removeItem(TokenKey)
    localStorage.removeItem(RefreshTokenKey)
}

//判断有没有登录
export function isAuth() {
    let token = getToken()
    if (token) {
        return true
    } else {
        return false
    }
}